import scrapy
import os
from demospider.items import TianqiItem

class TianqiSpider(scrapy.Spider):
    name = 'tianqi'
    allowed_domains = ['tianqi.com']

    # base_dir = os.path.dirname(os.path.abspath(__file__)) + '/'
    # filename = base_dir + '/data/tianqi.txt'

    
    start_urls = []
    cities = ['suzhou']
    for city in cities:
      start_urls.append('http://tianqi.com/' + city + '/')

    def parse(self, response):
        # filename = response.url.split("/")[-2]
        # with open(filename, 'wb') as f:
        #     f.write(response.body)
        print('请求体{}'.format(response.body))